package com.toidep.fragment.others;

import com.toidep.base.BaseFragment;

public class ModelDetailEventFragment extends BaseFragment {

//	private MainActivity mainActivity;
//
//	private View view;
//	private RelativeLayout layoutNoData;
//	private LinearLayout layoutLoading;
//	
//	private TextView textview_model_name, textview_event_name1, textview_event_name2, textview_event_name3, textview_event_description1;
//	private ImageView imageview_event1, imageview_event2, imageview_event3;
//	
//	private AmazingListView amazingListView;
//	private ArticleAdapter amazingAdapter;
//	
//	private ModelEntity modelEntity;
//	
//	public void setValues(ModelEntity modelEntity) {
//		this.modelEntity = modelEntity;
//	}
//	
//	/**
//	 * Set lai cac base value cho fragment: cac item cua thanh header, currentCategory cua menuSideBar
//	 */
//	public void setBaseValues() {
//		mainActivity.currentCategory = Constants.CATEGORY_MODEL;
//		mainActivity.mainFragment.setTittle(mainActivity.getString(R.string.label_category_model));
//		mainActivity.mainFragment.showButtonSlide(false);
//	}
//
//	@Override
//	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//
//		mainActivity = (MainActivity) getActivity();
//		view = inflater.inflate(R.layout.fragment_model_detail_tabs, container, false);
//
//		initComponents();
//		
//		setBaseValues();
//		
//		requestData();
//		
//		return view;
//	}
//
//	private void initComponents() {
//		
//		((ImageView) view.findViewById(R.id.imageview_icon)).setImageResource(R.drawable.icon_model_detail_event);
//		
//		layoutNoData = (RelativeLayout) view.findViewById(R.id.layoutNoData);
//		layoutNoData.setVisibility(View.GONE);
//		
//		layoutLoading = (LinearLayout) view.findViewById(R.id.layoutLoading);
//		layoutLoading.setVisibility(View.VISIBLE);
//		
//		// Khoi tao list model NEW
//		amazingListView = (AmazingListView) view.findViewById(R.id.amazingListView);
//		amazingListView.setAdapter(amazingAdapter = new ArticleAdapter(this, Constants.CATEGORY_MODEL_DETAL_EVENT, Constants.ARTICLE_MODE_NEWS, modelEntity.getId()));
//		
//		amazingAdapter.setAmazingListView(amazingListView, ConfigUtility.PAGE_SIZE);
//		amazingListView.setLoadingView(getActivity().getLayoutInflater().inflate(R.layout.layout_loading_view, null));
//		amazingListView.setDividerHeight(2);
//		
//		LinearLayout headerView =  (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.header_event, null);
//		amazingListView.addHeaderView(headerView);
//		
//		textview_model_name = (TextView) view.findViewById(R.id.textview_model_name);
//		
//		textview_event_name1 = (TextView) headerView.findViewById(R.id.textview_event_name1);
//		textview_event_name2 = (TextView) headerView.findViewById(R.id.textview_event_name2);
//		textview_event_name3 = (TextView) headerView.findViewById(R.id.textview_event_name3);
//		textview_event_description1 = (TextView) headerView.findViewById(R.id.textview_event_description1);
//		
//		imageview_event1 = (ImageView) headerView.findViewById(R.id.imageview_event1);
//		imageview_event2 = (ImageView) headerView.findViewById(R.id.imageview_event2);
//		imageview_event3 = (ImageView) headerView.findViewById(R.id.imageview_event3);
//		
//		textview_model_name.setText(String.format(mainActivity.getString(R.string.text_model_event_title), modelEntity.getName()));
//		
//		// Chuyen toi detail cua video
//		amazingListView.setOnItemClickListener(new OnItemClickListener() {
//			public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
//				if (amazingAdapter != null && position >= 0) {
//					amazingAdapter.onItemClick(position);
//				}
//			}
//		});
//	}
//	
//	/**
//	 * Goi API get list events dau tien 
//	 */
//	private void requestData() {
//		
//		ApiController.getArticlesOfModel(mainActivity, Constants.ARTICLE_MODE_NEWS, modelEntity.getId(),
//				1, ConfigUtility.PAGE_SIZE,
////				ApiController.getArticles(mainActivity, Constants.ARTICLE_MODE_EVENT, modelEntity.getId(), 1, 3,
//				new ResponseListener() {
//			
//			@Override
//			public void processResponse(int inintstall) {
//				// TODO Auto-generated method stub
//				
//			}
//			
//			@Override
//			public void processResponse(String response) {
//				processData(response);
//			}
//		});
//		
//	}
//	
//	private void processData(String response) {
//		AsyncTask<String, String, ArrayList<ArticleEntity>> asyn = new AsyncTask<String, String, ArrayList<ArticleEntity>>() {
//
//			@Override
//			protected ArrayList<ArticleEntity> doInBackground(String... params) {
//				if (params[0] != null) {
//					return ParseJSON.getAllArticlesObjectFromResponse(Constants.ARTICLE_MODE_NEWS, params[0]);
//				}
//				return null;
//			}
//			
//			@Override
//			protected void onPostExecute(ArrayList<ArticleEntity> lisNewsEntities) {
//				setWidgetInfo(lisNewsEntities);
//			}
//			
//		};
//		
//		asyn.execute(response);
//	}
//	
//	protected void setWidgetInfo(ArrayList<ArticleEntity> lisNewsEntities) {
//		layoutLoading.setVisibility(View.GONE);
//		if (lisNewsEntities == null) {
//			layoutNoData.setVisibility(View.VISIBLE);
//			return;
//		}
//		
////		ImageFetcher imageFetcher = mainActivity.mImageFetcher;
//		
//		textview_model_name.setText(String.format(mainActivity.getString(R.string.text_model_event_title), modelEntity.getName()));
//
//		int listSize = lisNewsEntities.size();
//		if (lisNewsEntities == null || listSize == 0) {
//			layoutNoData.setVisibility(View.VISIBLE);
//			return;
//		}
//		
//		ArticleEntity articleEntity1 = lisNewsEntities.get(0);
//		
//		int widthImage = ConfigUtility.size_full_width;
//		int heightImage = (int) (widthImage * ConfigUtility.scale_size_horizontal_thumbs_item);
//		
//		int widthImageView = ConfigUtility.scrWidth;
//		int heightImageView = (int) (widthImageView * ConfigUtility.scale_size_horizontal_thumbs_item);
//		
//		LinearLayout.LayoutParams param1 = new LinearLayout.LayoutParams(widthImageView, heightImageView);
//		imageview_event1.setLayoutParams(param1);
//		imageview_event1.setScaleType(ScaleType.FIT_XY);
//
//		mainActivity.loadImage(imageview_event1, articleEntity1.getImageUrl(), widthImage, heightImage, widthImageView, heightImageView);
//		
//		textview_event_name1.setText(articleEntity1.getTitle());
//		textview_event_description1.setText(articleEntity1.getIntroText());
//
//		int imgWidth = (ConfigUtility.scrWidth-20)/2;
//		float scale_thumb = ConfigUtility.scale_size_horizontal_thumbs_item;
//		
//		int widthImage2 = ConfigUtility.size_full_width;
//		int heightImage2 = (int) (widthImage * ConfigUtility.scale_size_horizontal_thumbs_item);
//		
//		int widthImageView2 = ConfigUtility.scrWidth;
//		int heightImageView2 = (int) (widthImageView * ConfigUtility.scale_size_horizontal_thumbs_item);
//		
//		RelativeLayout.LayoutParams param2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) (imgWidth*scale_thumb));
//		if (listSize >= 2) {
//			ArticleEntity articleEntity2 = lisNewsEntities.get(1);
//			imageFetcher.loadImage(articleEntity2.getImageUrl(), imageview_event2, null, imgWidth, (int) (imgWidth*scale_thumb), null);
//			imageview_event2.setLayoutParams(param2);
//			imageview_event2.setScaleType(ScaleType.FIT_XY);
//			
//			textview_event_name2.setText(articleEntity2.getTitle());
//		} else {
//			((LinearLayout) view.findViewById(R.id.layoutEvent2)).setVisibility(View.GONE);
//			return;
//		}
//		
//		if (listSize >= 3) {
//			ArticleEntity articleEntity3 = lisNewsEntities.get(2);
//			imageFetcher.loadImage(articleEntity3.getImageUrl(), imageview_event3, null, imgWidth, (int) (imgWidth*scale_thumb), null);
//			imageview_event3.setLayoutParams(param2);
//			imageview_event3.setScaleType(ScaleType.FIT_XY);
//			
//			textview_event_name3.setText(articleEntity3.getTitle());
//		}  else {
//			imageview_event3.setVisibility(View.GONE);
//			textview_event_name3.setVisibility(View.GONE);
//			return;
//		}
//		
//		if (listSize >= 4) {
//			amazingAdapter.notifyMayHaveMorePages();
//			
//			amazingAdapter.setAvatarImageSize();
//			
//			ArrayList<ArticleEntity> subList = new ArrayList<ArticleEntity>();
//			subList.addAll(lisNewsEntities.subList(3, listSize));			
//			amazingAdapter.resetList(subList);
//		}
//	}
	
	public static ModelDetailEventFragment newInstance() {
		ModelDetailEventFragment myFragment = new ModelDetailEventFragment();

		return myFragment;
	}

}
